const { authService } = require("./auth.service");

class AuthController {
	async login(ctx) {
		ctx.checkBody("userName").notEmpty("用户名不能为空");
		ctx.checkBody("password").notEmpty("密码不能为空");
		ctx.body = await authService.login(ctx.request.body);
	}
	logout(ctx) {
		return "退出登录";
	}
    async checkAuthState(ctx) {
        ctx.body = await authService.checkAuthState(ctx.state);
    }
    async wechatLogin(ctx) {
        ctx.body = await authService.wechatLogin(ctx.request.body);
    }
    async userRegister(ctx) {
        ctx.body = await authService.userRegister(ctx.request.body);
    }
    async getUserProfile(ctx) {
        ctx.body = await authService.getUserProfile(ctx.state);
    }
    async setPrivacyAgreement(ctx) {
        ctx.body = await authService.setPrivacyAgreement(ctx.state);
    }
}

module.exports = {
	authController: new AuthController()
};
